<template>
  <div>
   <button @click="ck()">点我</button>
    首页
    <SwiperCom />

    <van-row  gutter="20" v-for="(v,i) in newarr" :key="i">
      <van-col span="12" @click="fun(v[0].id)">
        <p>{{v[0].title}}</p>
      </van-col>
      <van-col span="12" @click="fun(v[1].id)">
        <p>{{v[0].title}}</p>
      </van-col>
  
    </van-row>

  
    <BottomBar />
  </div>
</template>

<script>
import SwiperCom from "@/components/SwiperCom.vue";
import {homelist} from "@/apis/link.js"


export default {

  components: {
    SwiperCom,
  },
  data(){
    return {
        arr:[]
    }
  },

  computed:{
    newarr(){
        let listarr=[]
        for(let i=0;i<this.arr.length;i+=2){
          
            listarr.push([this.arr[i],this.arr[i+1]])

        }
        console.log(listarr)


        return listarr
    }
  },

  mounted(){
    this.homefun()
  },

  methods:{
    

    async homefun(){
     let ok= await  homelist()
     console.log(ok.data)

    this.arr=ok.data
    },

     fun(i){
        console.log(i)
        // this.$router.push("/all")
        // params发送数据
        // this.$router.push({name:"all",params:{xiaoming:i}})

        // query方式
        this.$router.push({name:"all",query:{xiaoming:i}})
    }
  }
};
</script>

<style scoped>
p{
    height: 100px;
    background-color: aquamarine;
}
.van-row{
    margin: 10px 10px;
}
</style>